package api

import (
	"2212b/awesomeProject11/api/handler"
	"2212b/awesomeProject11/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func ToadRouters(r *gin.Engine) {
	r.GET("/ping", handler.Ping)
	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
			user.POST("/update", handler.UpdateToken)

		}
		chat := api.Group("chat")
		{
			chat.Use(jwt.JWTAuth(consts.JWT_KEY))
			chat.GET("/ws", handler.Chat)
		}
	}
}
